package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.seqdata.jpa.AbstractPersistable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "user_key")
public class UserKey extends AbstractPersistable<UserKeyId> {
	private static final long serialVersionUID = 1L;

	private User user;
	private CryotoKey cryotoKey;
	private byte[] secret;

	public UserKey() {
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "keyid", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.TypeSerializer.IdName.class)
	public CryotoKey getCryotoKey() {
		return this.cryotoKey;
	}

	public void setCryotoKey(CryotoKey cryotoKey) {
		this.cryotoKey = cryotoKey;
	}

	@Column(name = "secret")
	public byte[] getSecret() {
		return this.secret;
	}

	public void setSecret(byte[] secret) {
		this.secret = secret;
	}
}